/*
 *
 */
package org.jiscinvolve.astrodabis.barberry.common.core;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.junit.Test;
import org.junit.After;
import org.junit.Before;
import static org.junit.Assert.*;

import org.jiscinvolve.astrodabis.barberry.common.core.exception.*;

/*
 *
 */
public class AccountTestCase
extends CoreTestBase
    {

    @Test
    public void checkAccountNotNull()
        {
        assertNotNull(
            account()
            );
        }    

    @Test
    public void checkAccountIdentNotNull()
        {
        assertNotNull(
            account().ident()
            );
        }    

    @Test
    public void checkAccountNameNotNull()
        {
        assertNotNull(
            account().name()
            );
        }    

    @Test
    public void checkSelectByIdent()
        {
        compare(
            account(),
            womble().accounts().select(
                account().ident()
                )
            );
        }    

    @Test
    public void checkDupNameException()
        {
        try {
            womble().accounts().create(
                account().name(),
                "test-pass"
                );
            flush();
            fail(
                "DataIntegrityViolationException expected"
                );
            }
        catch (DuplicateEntryException ouch)
            {
            }
        }
    }

